const INFO_KEY = 'star_shopping_info'
const SEARCH_KEY = 'star_shoping_search'
// 数据本地持久化
export const getHistory = () => {
  const result = localStorage.getItem(SEARCH_KEY)
  return result ? JSON.parse(result) : []
}

export const setHistory = (arr) => {
  localStorage.setItem(SEARCH_KEY, JSON.stringify(arr))
}

export const getInfo = () => {
  const defaultObj = { token: '', userId: '' }
  const result = localStorage.getItem(INFO_KEY)
  return result ? JSON.parse(result) : defaultObj
}

export const setInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}

export const removetInfo = () => {
  localStorage.removeItem(INFO_KEY)
}
